<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="/connect.jspf"%>
<%@page import="model.LoginModel"%>
<%@page trimDirectiveWhitespaces="true" %>

<%
  String uname = request.getParameter("uname");
  String pass = request.getParameter("pass");
  String userid, full_name, email, gender, birth, avatar, about_me, post_count, comment_count;
  userid = full_name = email = gender = birth = avatar = about_me = post_count = comment_count = "";

  LoginModel lm = new LoginModel(con);
  ResultSet rs = lm.doLogin(uname, pass);

  int cnt = 0;
  while (rs.next()) {
    ++cnt;
    userid = rs.getString("ID");
    full_name = rs.getString("full_name");
    email = rs.getString("email");
    gender = rs.getString("gender");
    birth = rs.getString("birth");
    avatar = rs.getString("avatar");
    about_me = rs.getString("about_me");
    post_count = rs.getString("post_count");
    comment_count = rs.getString("comment_count");
  }
  
  if (cnt == 1) {
    session.setAttribute("userid", userid);
    session.setAttribute("uname", uname);
    session.setAttribute("full_name", full_name);
    session.setAttribute("email", email);
    session.setAttribute("gender", gender);
    session.setAttribute("birth", birth);
    session.setAttribute("avatar", avatar);
    session.setAttribute("about_me", about_me);
    session.setAttribute("post_count", post_count);
    session.setAttribute("comment_count", comment_count);
    out.write(userid);
  } else {
    out.write("no");
  }

%>

